package nature.nano.control.script.parse;

import nature.nano.component.EmptyProps;
import nature.nano.component.PrimaryPipe;
import nature.nano.component.SimpleProps;
import nature.nano.component.Strings;
import nature.nano.iface.Accepter;
import nature.nano.iface.Props;

public class ErrorHandleChecker extends PrimaryPipe {

	@Override
	public void anBegin(String type, Props props) {
		slot(Strings.output).onBegin(type, props);
	}
	
	@Override
	public void anContent(String content) {
		slot(Strings.output).onContent(content);
	}
	
	@Override
	public void anEnd(String type) {
		Accepter accepter = slot(Strings.output);
		if (type.equals(Strings.root)) {
			accepter.onBegin(Strings.row, EmptyProps.instance);
			accepter.onBegin(Strings.clazz, new SimpleProps(Strings.clazz, "Errors"));
			accepter.onEnd(Strings.clazz);
			accepter.onBegin(Strings.clazz, new SimpleProps(Strings.clazz, "RunningMessager"));
			accepter.onEnd(Strings.clazz);
			accepter.onBegin(Strings.clazz, new SimpleProps(Strings.clazz, "Printer"));
			accepter.onBegin(Strings.props, new SimpleProps(Strings.format, "half"));
			accepter.onEnd(Strings.props);
			accepter.onEnd(Strings.clazz);
			accepter.onEnd(Strings.row);						
		}
		accepter.onEnd(type);
	}
	
}
